clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAOD72FL.DTA", clear
rename capsu hv001
rename cahh hv002
rename caline hvidx
sort hv001 hv002 hvidx
gen hhcaste=cacasteh
replace hhcaste= hhcaste[_n-1] if hv002[_n-1]== hv002
replace hhcaste=cacastef if cacastef!=""
replace hhcaste=cacastem if cacastem!=""
drop if hvidx==0
save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/caste16", replace

clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAOD72FL.DTA", clear
rename capsu hv001
rename cahh hv002
rename caline hvidx
sort hv001 hv002 hvidx
gen castename=cacasteh
keep if hvidx==0
save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/caste16hh", replace

clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAPR23FL.DTA"
keep hhid hvidx sh033 sh034 sh035 shcaste shoccup hv001 hv002 hv007 hv024 hv028 hv106 hv107 hv105 hv005

gen v003=hvidx
gen v001= hv001
gen v002= hv002
merge 1:1 v001 v002 v003 using "/Users/alee87/Dropbox/Job Reservation/Raw Data/IAIR23FL.dta" , keepusing(v704 v705 v716 v717 )

gen year=1993
keep if shcaste==2
keep if hv105>18 &hv105<61

gen state=""
replace state="Arunachal Pradesh" if hv024==34
replace state="Nagaland" if hv024==17
replace state="Manipur" if hv024==14
replace state="Mizoram" if hv024==16
replace state="Meghalaya" if hv024==15
replace state="Goa" if hv024==5
replace state="West Bengal" if hv024==23
replace state="Assam" if hv024==3
replace state="Delhi" if hv024==30
replace state="Maharashtra" if hv024==13
replace state="Orissa" if hv024==18
replace state="Haryana" if hv024==7
replace state="Madhya Pradesh" if hv024==12
replace state="Punjab" if hv024==19
replace state="Himachal Pradesh" if hv024==8
replace state="Bihar" if hv024==4
replace state="Andhra Pradesh" if hv024==2
replace state="Karnataka" if hv024==10
replace state="Tamil Nadu" if hv024==22
replace state="Gujarat" if hv024==6
replace state="Kerala" if hv024==11
replace state="Rajasthan" if hv024==20
replace state="Uttar Pradesh" if hv024==24


save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm93.dta", replace

clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAPR42FL copy.DTA"
keep hhid sh40 sh40ct sh41 sh17 hv001 hv002 hv007 hv024 hv028 hv106 hv107 hv105 hv003 hvidx hv005

gen v003=hvidx
gen v001= hv001
gen v002= hv002
gen v024= hv024
merge 1:1 v001 v002 v003 v024  using "/Users/alee87/Dropbox/Job Reservation/Raw Data/IAIR42FL.dta" , keepusing(v704 v705 v716 v717 )


keep if hv105>18 &hv105<61
keep if  sh41>2
gen year=1999

gen state=""
replace state="Jammu & Kashmir" if hv024==9
replace state="Arunachal Pradesh" if hv024==34
replace state="Nagaland" if hv024==17
replace state="Manipur" if hv024==14
replace state="Mizoram" if hv024==16
replace state="Meghalaya" if hv024==15
replace state="Goa" if hv024==5
replace state="West Bengal" if hv024==23
replace state="Assam" if hv024==3
replace state="Delhi" if hv024==30
replace state="Maharashtra" if hv024==13
replace state="Orissa" if hv024==18
replace state="Haryana" if hv024==7
replace state="Madhya Pradesh" if hv024==12
replace state="Punjab" if hv024==19
replace state="Himachal Pradesh" if hv024==8
replace state="Bihar" if hv024==4
replace state="Andhra Pradesh" if hv024==2
replace state="Karnataka" if hv024==10
replace state="Tamil Nadu" if hv024==22
replace state="Gujarat" if hv024==6
replace state="Kerala" if hv024==11
replace state="Rajasthan" if hv024==20
replace state="Uttar Pradesh" if hv024==24

save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm99.dta", replace

clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAPR52FL copy.DTA"
keep hhid sh45 sh46  hv001 hv002 hv003 hv007 hv024 hv028 hv106 hv107 hv105 hvidx hv005
gen v003=hvidx
gen v001= hv001
gen v002= hv002
merge 1:1 v001 v002 v003 using "/Users/alee87/Dropbox/Job Reservation/Raw Data/IAIR52FL.dta" , keepusing(v704 v705 v716 v717 v034)
drop _merge
gen mv003=hvidx
gen mv001= hv001
gen mv002= hv002
merge 1:1 mv001 mv002 mv003 using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAMR52FL.dta", keepusing( mv716 mv717 )
drop _merge
gen year=2006
gen ctstate=hv024
gen ctpsu= hv001-hv024*1000
gen cthouse=hv002
gen ctind=.
merge m:1 ctstate ctpsu cthouse  ctind using "/Users/alee87/Dropbox/Job Reservation/Raw Data/castetribe.dta"
drop if _merge==2
drop _merge
keep if  sh46>2
keep if hv105>18 &hv105<61

gen state=""
replace state="Jammu & Kashmir" if hv024==1
replace state="Sikkim" if hv024==11
replace state="Arunachal Pradesh" if hv024==12
replace state="Nagaland" if hv024==13
replace state="Manipur" if hv024==14
replace state="Mizoram" if hv024==15
replace state="Meghalaya" if hv024==17
replace state="Goa" if hv024==30
replace state="Jharkhand" if hv024==20
replace state="West Bengal" if hv024==19
replace state="Assam" if hv024==18
replace state="Chhattisgarh" if hv024==22
replace state="Uttaranchal" if hv024==5
replace state="Delhi" if hv024==7
replace state="Maharashtra" if hv024==27
replace state="Orissa" if hv024==21
replace state="Haryana" if hv024==6
replace state="Madhya Pradesh" if hv024==23
replace state="Punjab" if hv024==3
replace state="Himachal Pradesh" if hv024==2
replace state="Bihar" if hv024==10
replace state="Andhra Pradesh" if hv024==28
replace state="Andhra Pradesh" if hv024==36
replace state="Karnataka" if hv024==29
replace state="Tamil Nadu" if hv024==33
replace state="Gujarat" if hv024==24
replace state="Kerala" if hv024==32
replace state="Rajasthan" if hv024==8
replace state="Uttar Pradesh" if hv024==9


replace state="Bihar" if state=="Jharkhand"
replace state="Uttar Pradesh" if state=="Uttaranchal"
replace state="Madhya Pradesh" if state=="Chhattisgarh"

save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm06.dta", replace


clear
use "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAPR74FL.DTA"
keep hhid  hvidx sh35 sh36 hv001 hv002 hv003 hv007 hv024 hv028 hv106 hv107 hv105 hv005
gen v003=hvidx 
gen v001= hv001
gen v002= hv002
merge 1:1 v001 v002 v003 using  "/Users/alee87/Dropbox/Data/India DHS/IAIR74DT/IAIR74FL.DTA" , keepusing(v704 v705 v716 v717 v034)
drop _merge
gen mv003=hvidx
gen mv001= hv001
gen mv002= hv002
merge 1:1 mv001 mv002 mv003 using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/IAMR74FL.DTA", keepusing( mv716 mv717 )
drop _merge
merge 1:1 hv001 hv002 hvidx using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/caste16"
drop if _merge==2
drop _merge
merge  m:1 hv001 hv002  using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/caste16hh"
drop if _merge==2
drop _merge
replace castename=hhcaste if hhcaste!=""
sort hv001 hv002 hvidx
replace castename= castename[_n-1] if hv002[_n-1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""
replace castename= castename[_n+1] if hv002[_n+1]== hv002 &castename==""

gen state=""
replace state="Jammu & Kashmir" if hv024==14
replace state="Sikkim" if hv024==30
replace state="Arunachal Pradesh" if hv024==3
replace state="Nagaland" if hv024==24
replace state="Manipur" if hv024==21
replace state="Mizoram" if hv024==23
replace state="Meghalaya" if hv024==22
replace state="Goa" if hv024==10
replace state="Jharkhand" if hv024==15
replace state="West Bengal" if hv024==35
replace state="Assam" if hv024==4
replace state="Chhattisgarh" if hv024==7
replace state="Uttaranchal" if hv024==34
replace state="Delhi" if hv024==25
replace state="Maharashtra" if hv024==20
replace state="Orissa" if hv024==26
replace state="Haryana" if hv024==12
replace state="Madhya Pradesh" if hv024==19
replace state="Punjab" if hv024==28
replace state="Himachal Pradesh" if hv024==13
replace state="Bihar" if hv024==5
replace state="Andhra Pradesh" if hv024==2
replace state="Karnataka" if hv024==16
replace state="Tamil Nadu" if hv024==31
replace state="Gujarat" if hv024==11
replace state="Kerala" if hv024==17
replace state="Rajasthan" if hv024==29
replace state="Uttar Pradesh" if hv024==33


replace state="Bihar" if state=="Jharkhand"
replace state="Uttar Pradesh" if state=="Uttaranchal"
replace state="Madhya Pradesh" if state=="Chhattisgarh"

gen year=2016
keep if  sh36>2
keep if hv105>18 &hv105<61


append using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm06.dta"
append using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm99.dta"
append using "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/hm93.dta"

drop v003 v001 v002 mv003 mv001 mv002 _merge



merge m:1 state using "/Users/alee87/Dropbox/Job Reservation/Replication/states_notes.dta"
drop if _merge==2
gen stategrp=0
replace stategrp =1 if obc_res_year>1990

*castecodes 92
gen castecode=sh035
replace castecode=sh034 if sh035==.
replace castecode=8888 if sh035==0 &sh033==1
recode castecode (9998=9999) (9996=9999) (9997=.)

replace castecode=	9	if castecode==	854
replace castecode=	9	if castecode==	1942
replace castecode=	9	if castecode==	1946
replace castecode=	9	if castecode==	1947
replace castecode=	14	if castecode==	1955
replace castecode=	14	if castecode==	1957
replace castecode=	14	if castecode==	1961
replace castecode=	14	if castecode==	1964
replace castecode=	21	if castecode==	1968
replace castecode=	31	if castecode==	1971
replace castecode=	32	if castecode==	1979
replace castecode=	43	if castecode==	1992
replace castecode=	46	if castecode==	81
replace castecode=	49	if castecode==	6
replace castecode=	49	if castecode==	615
replace castecode=	49	if castecode==	700
replace castecode=	49	if castecode==	1998
replace castecode=	49	if castecode==	2000
replace castecode=	49	if castecode==	2001
replace castecode=	49	if castecode==	2004
replace castecode=	49	if castecode==	2005
replace castecode=	50	if castecode==	2010
replace castecode=	52	if castecode==	2016
replace castecode=	52	if castecode==	2017
replace castecode=	57	if castecode==	2024
replace castecode=	57	if castecode==	2029
replace castecode=	57	if castecode==	2034
replace castecode=	58	if castecode==	85
replace castecode=	61	if castecode==	2037
replace castecode=	65	if castecode==	2041
replace castecode=	89	if castecode==	90
replace castecode=	93	if castecode==	2072
replace castecode=	118	if castecode==	2107
replace castecode=	118	if castecode==	2108
replace castecode=	118	if castecode==	2109
replace castecode=	118	if castecode==	2128
replace castecode=	118	if castecode==	2176
replace castecode=	118	if castecode==	2196
replace castecode=	118	if castecode==	2210
replace castecode=	118	if castecode==	2226
replace castecode=	118	if castecode==	2253
replace castecode=	118	if castecode==	2261
replace castecode=	118	if castecode==	2263
replace castecode=	118	if castecode==	2269
replace castecode=	126	if castecode==	2280
replace castecode=	142	if castecode==	467
replace castecode=	178	if castecode==	52
replace castecode=	181	if castecode==	2304
replace castecode=	181	if castecode==	2307
replace castecode=	182	if castecode==	316
replace castecode=	195	if castecode==	2319
replace castecode=	223	if castecode==	2323
replace castecode=	223	if castecode==	2324
replace castecode=	226	if castecode==	2326
replace castecode=	231	if castecode==	2334
replace castecode=	252	if castecode==	2344
replace castecode=	259	if castecode==	2383
replace castecode=	268	if castecode==	2387
replace castecode=	283	if castecode==	324
replace castecode=	294	if castecode==	2391
replace castecode=	317	if castecode==	321
replace castecode=	326	if castecode==	2418
replace castecode=	326	if castecode==	2421
replace castecode=	331	if castecode==	2427
replace castecode=	335	if castecode==	2436
replace castecode=	353	if castecode==	2446
replace castecode=	353	if castecode==	2449
replace castecode=	362	if castecode==	2453
replace castecode=	363	if castecode==	2455
replace castecode=	363	if castecode==	2457
replace castecode=	368	if castecode==	706
replace castecode=	381	if castecode==	2472
replace castecode=	396	if castecode==	2479
replace castecode=	416	if castecode==	419
replace castecode=	422	if castecode==	2491
replace castecode=	430	if castecode==	2495
replace castecode=	472	if castecode==	1384
replace castecode=	474	if castecode==	2544
replace castecode=	483	if castecode==	2585
replace castecode=	494	if castecode==	2594
replace castecode=	506	if castecode==	2609
replace castecode=	506	if castecode==	2612
replace castecode=	516	if castecode==	181
replace castecode=	516	if castecode==	2626
replace castecode=	516	if castecode==	2628
replace castecode=	516	if castecode==	2629
replace castecode=	518	if castecode==	2631
replace castecode=	520	if castecode==	2634
replace castecode=	528	if castecode==	2635
replace castecode=	549	if castecode==	1492
replace castecode=	591	if castecode==	2655
replace castecode=	591	if castecode==	2656
replace castecode=	591	if castecode==	2657
replace castecode=	600	if castecode==	2662
replace castecode=	614	if castecode==	2672
replace castecode=	619	if castecode==	635
replace castecode=	619	if castecode==	721
replace castecode=	628	if castecode==	2673
replace castecode=	630	if castecode==	2676
replace castecode=	651	if castecode==	199
replace castecode=	691	if castecode==	193
replace castecode=	691	if castecode==	696
replace castecode=	691	if castecode==	793
replace castecode=	691	if castecode==	2712
replace castecode=	691	if castecode==	2714
replace castecode=	691	if castecode==	2717
replace castecode=	691	if castecode==	2718
replace castecode=	691	if castecode==	2730
replace castecode=	691	if castecode==	2739
replace castecode=	691	if castecode==	2740
replace castecode=	691	if castecode==	2743
replace castecode=	691	if castecode==	2749
replace castecode=	691	if castecode==	2753
replace castecode=	691	if castecode==	2761
replace castecode=	691	if castecode==	2765
replace castecode=	691	if castecode==	2775
replace castecode=	691	if castecode==	2781
replace castecode=	691	if castecode==	2784
replace castecode=	691	if castecode==	2785
replace castecode=	691	if castecode==	2787
replace castecode=	691	if castecode==	2791
replace castecode=	691	if castecode==	2794
replace castecode=	691	if castecode==	2795
replace castecode=	697	if castecode==	698
replace castecode=	705	if castecode==	704
replace castecode=	714	if castecode==	716
replace castecode=	724	if castecode==	2810
replace castecode=	736	if castecode==	712
replace castecode=	740	if castecode==	2820
replace castecode=	744	if castecode==	2829
replace castecode=	744	if castecode==	3014
replace castecode=	747	if castecode==	2832
replace castecode=	783	if castecode==	2841
replace castecode=	822	if castecode==	2856
replace castecode=	823	if castecode==	1447
replace castecode=	823	if castecode==	2857
replace castecode=	823	if castecode==	2858
replace castecode=	823	if castecode==	2859
replace castecode=	823	if castecode==	2860
replace castecode=	823	if castecode==	2861
replace castecode=	823	if castecode==	2863
replace castecode=	823	if castecode==	2865
replace castecode=	823	if castecode==	2866
replace castecode=	823	if castecode==	2867
replace castecode=	824	if castecode==	2868
replace castecode=	827	if castecode==	2869
replace castecode=	827	if castecode==	2870
replace castecode=	827	if castecode==	2871
replace castecode=	828	if castecode==	619
replace castecode=	828	if castecode==	628
replace castecode=	828	if castecode==	2872
replace castecode=	828	if castecode==	2873
replace castecode=	828	if castecode==	2874
replace castecode=	828	if castecode==	2875
replace castecode=	828	if castecode==	2876
replace castecode=	830	if castecode==	2877
replace castecode=	833	if castecode==	453
replace castecode=	833	if castecode==	673
replace castecode=	833	if castecode==	2506
replace castecode=	833	if castecode==	2878
replace castecode=	833	if castecode==	2882
replace castecode=	833	if castecode==	2883
replace castecode=	838	if castecode==	2884
replace castecode=	844	if castecode==	2885
replace castecode=	844	if castecode==	2886
replace castecode=	849	if castecode==	2887
replace castecode=	849	if castecode==	2888
replace castecode=	851	if castecode==	2889
replace castecode=	2445	if castecode==	2445
replace castecode=	2879	if castecode==	2879
replace castecode=	2879	if castecode==	2880
replace castecode=	2879	if castecode==	2881
replace castecode=	9999	if castecode==	906
replace castecode=	9999	if castecode==	998
replace castecode=	9999	if castecode==	999
replace castecode=	9999	if castecode==	1000
replace castecode=	9999	if castecode==	1396

*castenames

replace castename="MUKADORA" if castecode==4
replace castename="AGRI" if castecode==5
replace castename="AGURI" if castecode==7
replace castename="YADAV" if castecode==9
replace castename="AHOM" if castecode==10
replace castename="AMBALAKAR" if castecode==13
replace castename="AANDH" if castecode==15
replace castename="ARAB" if castecode==18
replace castename="ARORA" if castecode==22
replace castename="BAGDI" if castecode==31
replace castename="BARUI" if castecode==32
replace castename="BAIDYA" if castecode==34
replace castename="BAIRAGI" if castecode==37
replace castename="BAJAJ" if castecode==39
replace castename="BALAI" if castecode==41
replace castename="BALASHI" if castecode==42
replace castename="BALIJA" if castecode==43
replace castename="BANDARI" if castecode==46
replace castename="BANIA" if castecode==49
replace castename="BANJARA" if castecode==50
replace castename="SUTAR" if castecode==57
replace castename="BARAI" if castecode==58
replace castename="BARIK" if castecode==59
replace castename="BARIWA" if castecode==61
replace castename="BATHUDI" if castecode==64
replace castename="BAURI" if castecode==65
replace castename="BEDA" if castecode==67
replace castename="BELADAR" if castecode==68
replace castename="BESTA" if castecode==75
replace castename="BHANGI" if castecode==82
replace castename="BHAR" if castecode==84
replace castename="BHARBHUJA" if castecode==86
replace castename="BHARWAD" if castecode==88
replace castename="BHAT" if castecode==89
replace castename="BHIL" if castecode==92
replace castename="BHOI" if castecode==94
replace castename="BHUMIHAR" if castecode==96
replace castename="BHUIYA" if castecode==97
replace castename="BHUMIJ" if castecode==99
replace castename="BIND" if castecode==105
replace castename="BORI" if castecode==113
replace castename="BRAHMAN" if castecode==118
replace castename="BUNKAR" if castecode==122
replace castename="CHAMAR" if castecode==126
replace castename="CHASA" if castecode==133
replace castename="CHAUHAN" if castecode==139
replace castename="CHHIPA" if castecode==142
replace castename="CHUTIA" if castecode==151
replace castename="DALUA" if castecode==157
replace castename="DANGI" if castecode==160
replace castename="MIR" if castecode==163
replace castename="DARJI" if castecode==165
replace castename="DAS" if castecode==168
replace castename="DEVANGA" if castecode==171
replace castename="DHAKAR" if castecode==176
replace castename="DHANGAR" if castecode==177
replace castename="DHANAK" if castecode==178
replace castename="DHIMAR" if castecode==182
replace castename="DOBHI" if castecode==184
replace castename="DHUNIYA" if castecode==190
replace castename="DHOLI" if castecode==194
replace castename="DOM" if castecode==195
replace castename="HALPATI" if castecode==197
replace castename="YANADI" if castecode==202
replace castename="ERUKALA" if castecode==206
replace castename="FAQIR" if castecode==207
replace castename="GADABA" if castecode==208
replace castename="GADARIA" if castecode==209
replace castename="GADDI" if castecode==210
replace castename="GAMIT" if castecode==216
replace castename="GANDA" if castecode==218
replace castename="GANIGA" if castecode==223
replace castename="GARO" if castecode==227
replace castename="GOUD" if castecode==231
replace castename="GAVALI" if castecode==234
replace castename="GHATWAR" if castecode==242
replace castename="GHIRATH" if castecode==243
replace castename="GOKHA" if castecode==249
replace castename="THEVAR" if castecode==252
replace castename="GOND" if castecode==253
replace castename="GOPAL" if castecode==257
replace castename="GOSAI" if castecode==259
replace castename="GUJAR" if castecode==261
replace castename="GURAV" if castecode==263
replace castename="NAI" if castecode==268
replace castename="HALWAI" if castecode==274
replace castename="HARI" if castecode==278
replace castename="HATKAR" if castecode==283
replace castename="EZHAVA" if castecode==294
replace castename="JANGIR" if castecode==302
replace castename="JANGAM" if castecode==305
replace castename="JAT" if castecode==308
replace castename="JOGI" if castecode==317
replace castename="JULAHA" if castecode==322
replace castename="KABBALIGA" if castecode==323
replace castename="KACCHI" if castecode==326
replace castename="KAHAR" if castecode==331
replace castename="KAIBARTA" if castecode==333
replace castename="ARAYA" if castecode==334
replace castename="KURAVAR" if castecode==335
replace castename="KALINGA" if castecode==339
replace castename="KALITA" if castecode==340
replace castename="KALAL" if castecode==341
replace castename="KAMAR" if castecode==347
replace castename="KAMBALATHUNAIKAR" if castecode==349
replace castename="KAMBOJ" if castecode==350
replace castename="KAMMA" if castecode==352
replace castename="KAMSALI" if castecode==353
replace castename="KANJAR" if castecode==363
replace castename="KAPU" if castecode==368
replace castename="KARAN" if castecode==373
replace castename="KIRAR" if castecode==374
replace castename="KASAR" if castecode==381
replace castename="KATIYA" if castecode==393
replace castename="KAWAR" if castecode==395
replace castename="KAYASTH" if castecode==396
replace castename="KEWAT" if castecode==401
replace castename="KHANDAYAT" if castecode==408
replace castename="KHANDELWAL" if castecode==409
replace castename="KHANGAR" if castecode==410
replace castename="KHARIA" if castecode==416
replace castename="KHERWAR" if castecode==416
replace castename="KHASI" if castecode==420
replace castename="KHATIK" if castecode==422
replace castename="KHATRI" if castecode==423
replace castename="QUERESHI" if castecode==433
replace castename="KEER" if castecode==435
replace castename="KISAN" if castecode==436
replace castename="KOCH" if castecode==437
replace castename="KODAVA" if castecode==438
replace castename="KOL" if castecode==444
replace castename="KOLI" if castecode==447
replace castename="KORI" if castecode==456
replace castename="KORKU" if castecode==457
replace castename="KOSHTI" if castecode==459
replace castename="KUDUMBI" if castecode==469
replace castename="KUMHAR" if castecode==472
replace castename="KUNBI" if castecode==474
replace castename="KURUBA" if castecode==479
replace castename="KURUHINA SHETTY" if castecode==482
replace castename="KUMAR" if castecode==483
replace castename="LABBAI" if castecode==486
replace castename="LALUNG" if castecode==488
replace castename="LINGAYAT" if castecode==495
replace castename="LODH" if castecode==496
replace castename="LOHANA" if castecode==497
replace castename="LOHAR" if castecode==498
replace castename="LUNIYA" if castecode==500
replace castename="MACHHI" if castecode==502
replace castename="MADAHI" if castecode==503
replace castename="MADARA" if castecode==505
replace castename="MADIGA" if castecode==506
replace castename="MAKRANI" if castecode==514
replace castename="MALA" if castecode==516
replace castename="MALI" if castecode==520
replace castename="MALIK" if castecode==521
replace castename="MALLAH" if castecode==522
replace castename="MANA" if castecode==524
replace castename="MANG" if castecode==528
replace castename="MANGALA" if castecode==529
replace castename="MANIHAR" if castecode==532
replace castename="MANIPURI" if castecode==533
replace castename="MANJHI" if castecode==534
replace castename="MAPPILA" if castecode==537
replace castename="MARAVAR" if castecode==538
replace castename="MEGH" if castecode==547
replace castename="MAHAR" if castecode==549
replace castename="MEMAN" if castecode==550
replace castename="MEO" if castecode==551
replace castename="MEENA" if castecode==556
replace castename="MIRASI" if castecode==557
replace castename="MODI" if castecode==561
replace castename="MUGHAL" if castecode==567
replace castename="MUNDA" if castecode==570
replace castename="MUSHAHAR" if castecode==579
replace castename="MUDIRAJ" if castecode==582
replace castename="NADAVARU" if castecode==584
replace castename="NAIR" if castecode==591
replace castename="NAYAK" if castecode==602
replace castename="NEPALI" if castecode==603
replace castename="NOLIA" if castecode==609
replace castename="ORAON" if castecode==613
replace castename="ROR" if castecode==614
replace castename="OTTAR" if castecode==616
replace castename="PADMASALI" if castecode==619
replace castename="PAHARIA" if castecode==621
replace castename="PANA" if castecode==630
replace castename="PANDARA" if castecode==638
replace castename="PANIKA" if castecode==644
replace castename="PARAIYAR" if castecode==647
replace castename="PARAJA" if castecode==648
replace castename="PARAVAR" if castecode==650
replace castename="PASI" if castecode==651
replace castename="PATEL" if castecode==654
replace castename="PATHAN" if castecode==655
replace castename="PATRA" if castecode==660
replace castename="PERIKA" if castecode==668
replace castename="POD" if castecode==675
replace castename="PAWAR" if castecode==677
replace castename="POOJARY" if castecode==679
replace castename="PULAYAN" if castecode==680
replace castename="RABARI" if castecode==686
replace castename="RABHA" if castecode==687
replace castename="RAJPUT" if castecode==691
replace castename="RAJU" if castecode==692
replace castename="RAJVAR" if castecode==693
replace castename="RANGREJ" if castecode==697
replace castename="RAVAL" if castecode==704
replace castename="RAWAT" if castecode==705
replace castename="RAIGAR" if castecode==707
replace castename="RAZAKA" if castecode==708
replace castename="SADGOP" if castecode==713
replace castename="SAHRIYA" if castecode==714
replace castename="SARGARA" if castecode==715
replace castename="SANKHARI" if castecode==727
replace castename="SANTHAL" if castecode==729
replace castename="SAPARA" if castecode==732
replace castename="SATNAMI" if castecode==736
replace castename="SABAR" if castecode==740
replace castename="SAID" if castecode==741
replace castename="SAHA" if castecode==743
replace castename="SHEIK" if castecode==746
replace castename="ALVI" if castecode==747
replace castename="CHETTI" if castecode==749
replace castename="SHUKLA" if castecode==753
replace castename="SIDDH" if castecode==754
replace castename="SINDHI" if castecode==756
replace castename="SONAR" if castecode==761
replace castename="SORATHIYA" if castecode==763
replace castename="SONUWAL" if castecode==769
replace castename="SUNDHI" if castecode==771
replace castename="TAMBOLI" if castecode==783
replace castename="TANTI" if castecode==785
replace castename="THATTAN" if castecode==787
replace castename="TELI" if castecode==791
replace castename="THOGATA" if castecode==803
replace castename="TURI" if castecode==810
replace castename="UDAIYAR" if castecode==814
replace castename="UPPARA" if castecode==819
replace castename="VAISHNAV" if castecode==822
replace castename="VOKKALIGA" if castecode==823
replace castename="MANNAN" if castecode==827
replace castename="VANNAN" if castecode==827
replace castename="VANNIYAR" if castecode==828
replace castename="VELAMA" if castecode==832
replace castename="VELLALA" if castecode==833
replace castename="VARALI" if castecode==851
replace castename="BADHAI" if castecode==901
replace castename="BANT" if castecode==929
replace castename="BARGAKHATI" if castecode==936
replace castename="TIGALA" if castecode==980
replace castename="BODH" if castecode==991
replace castename="MARATHA" if castecode==996
replace castename="BUKSA" if castecode==1019
replace castename="GANGWAR" if castecode==1171
replace castename="HADI" if castecode==1219
replace castename="KANODIA" if castecode==1337
replace castename="KHANT" if castecode==1339
replace castename="MAKVANA" if castecode==1497
replace castename="MANSOORI" if castecode==1514
replace castename="MATHUR" if castecode==1531
replace castename="PRADHAN" if castecode==1689
replace castename="PURI" if castecode==1695
replace castename="HO" if castecode==1717
replace castename="SODHI" if castecode==1801
replace castename="THAPA" if castecode==1849
replace castename="IDIGA" if castecode==2825
replace castename="VADDERA" if castecode==2877
replace castename="NADAR" if castecode==3014
replace castename="ADIVASI" if castecode==8888
replace castename="?" if castecode==0
replace castename="?" if castecode==9999

replace castename="Other" if castename==""

replace castename=upper(ctresp) if ctresp!=""
replace castename=upper(sh40ct) if sh40ct!=""
replace castename=trim(castename)
replace castename = subinstr(castename, "  ", " ",.)
replace castename = subinstr(castename, "/", " ",.)


do "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/castespellings"

*category variable
gen category="general"

replace category="obc" if  castename=="BARAI" & state=="Assam"
replace category="obc" if  castename=="BARUI" & state=="Assam"
replace category="obc" if  castename=="BHIL" & state=="Assam"
replace category="obc" if  castename=="BHUMIJ" & state=="Assam"
replace category="obc" if  castename=="CHUTIA" & state=="Assam"
replace category="obc" if  castename=="JOGI" & state=="Assam"
replace category="obc" if  castename=="KACCHI" & state=="Assam"
replace category="obc" if  castename=="KAWAR" & state=="Assam"
replace category="obc" if  castename=="KOCH" & state=="Assam"
replace category="obc" if  castename=="LUNIYA" & state=="Assam"
replace category="obc" if  castename=="MANIPURI" & state=="Assam"
replace category="obc" if  castename=="MUNDA" & state=="Assam"
replace category="obc" if  castename=="NEPALI" & state=="Assam"
replace category="obc" if  castename=="ORAON" & state=="Assam"
replace category="obc" if  castename=="PASI" & state=="Assam"
replace category="obc" if  castename=="SANTHAL" & state=="Assam"
replace category="obc" if  castename=="TELI" & state=="Assam"
replace category="obc" if  castename=="AGRI" & state=="Bihar"
replace category="obc" if  castename=="BANIA" & state=="Bihar"
replace category="obc" if  castename=="BARAI" & state=="Bihar"
replace category="obc" if  castename=="BHAT" & state=="Bihar"
replace category="obc" if  castename=="DHANAK" & state=="Bihar"
replace category="obc" if  castename=="DHIMAR" & state=="Bihar"
replace category="obc" if  castename=="GOUD" & state=="Bihar"
replace category="obc" if  castename=="JOGI" & state=="Bihar"
replace category="obc" if  castename=="KACCHI" & state=="Bihar"
replace category="obc" if  castename=="KAHAR" & state=="Bihar"
replace category="obc" if  castename=="KALAL" & state=="Bihar"
replace category="obc" if  castename=="KHATIK" & state=="Bihar"
replace category="obc" if  castename=="KOCH" & state=="Bihar"
replace category="obc" if  castename=="KUNBI" & state=="Bihar"
replace category="obc" if  castename=="LOHAR" & state=="Bihar"
replace category="obc" if  castename=="LUNIYA" & state=="Bihar"
replace category="obc" if  castename=="MALI" & state=="Bihar"
replace category="obc" if  castename=="MALLAH" & state=="Bihar"
replace category="obc" if  castename=="NAI" & state=="Bihar"
replace category="obc" if  castename=="SONAR" & state=="Bihar"
replace category="obc" if  castename=="TANTI" & state=="Bihar"
replace category="obc" if  castename=="TELI" & state=="Bihar"
replace category="obc" if  castename=="YADAV" & state=="Bihar"
replace category="obc" if  castename=="BHARWAD" & state=="Gujarat"
replace category="obc" if  castename=="BHOI" & state=="Gujarat"
replace category="obc" if  castename=="DOBHI" & state=="Gujarat"
replace category="obc" if  castename=="FAQIR" & state=="Gujarat"
replace category="obc" if  castename=="JULAHA" & state=="Gujarat"
replace category="obc" if  castename=="KAHAR" & state=="Gujarat"
replace category="obc" if  castename=="KHATIK" & state=="Gujarat"
replace category="obc" if  castename=="KOLI" & state=="Gujarat"
replace category="obc" if  castename=="LODH" & state=="Gujarat"
replace category="obc" if  castename=="MACHHI" & state=="Gujarat"
replace category="obc" if  castename=="MAKRANI" & state=="Gujarat"
replace category="obc" if  castename=="MEENA" & state=="Gujarat"
replace category="obc" if  castename=="NAI" & state=="Gujarat"
replace category="obc" if  castename=="PADMASALI" & state=="Gujarat"
replace category="obc" if  castename=="RAVAL" & state=="Gujarat"
replace category="obc" if  castename=="YADAV" & state=="Gujarat"
replace category="obc" if  castename=="BAIRAGI" & state=="Haryana"
replace category="obc" if  castename=="BANJARA" & state=="Haryana"
replace category="obc" if  castename=="BHAT" & state=="Haryana"
replace category="obc" if  castename=="DARJI" & state=="Haryana"
replace category="obc" if  castename=="DHIMAR" & state=="Haryana"
replace category="obc" if  castename=="DOBHI" & state=="Haryana"
replace category="obc" if  castename=="FAQIR" & state=="Haryana"
replace category="obc" if  castename=="GADARIA" & state=="Haryana"
replace category="obc" if  castename=="KAMBOJ" & state=="Haryana"
replace category="obc" if  castename=="KANJAR" & state=="Haryana"
replace category="obc" if  castename=="LOHAR" & state=="Haryana"
replace category="obc" if  castename=="SONAR" & state=="Haryana"
replace category="obc" if  castename=="TELI" & state=="Haryana"
replace category="obc" if  castename=="YADAV" & state=="Haryana"
replace category="obc" if  castename=="BHAT" & state=="Himachal Pradesh"
replace category="obc" if  castename=="DHIMAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="FAQIR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="GADDI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="GUJAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="KAHAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="KUMHAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="KUNBI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="MALI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="BHANGI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="KUMHAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="LOHAR" & state=="Himachal Pradesh"
replace category="obc" if  castename=="NAI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="TELI" & state=="Himachal Pradesh"
replace category="obc" if  castename=="BAIRAGI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BANJARA" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BARAI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BHARBHUJA" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BHAT" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BHOI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="DANGI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="DARJI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="DHANGAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="DHIMAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="DOBHI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="FAQIR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="GADARIA" & state=="Madhya Pradesh"
replace category="obc" if  castename=="GUJAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="HATKAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KAHAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KALAL" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KASAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KIRAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KOSHTI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="KUNBI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="LODH" & state=="Madhya Pradesh"
replace category="obc" if  castename=="LOHAR" & state=="Madhya Pradesh"
replace category="obc" if  castename=="LUNIYA" & state=="Madhya Pradesh"
replace category="obc" if  castename=="MALI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="NAI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="TELI" & state=="Madhya Pradesh"
replace category="obc" if  castename=="YADAV" & state=="Madhya Pradesh"
replace category="obc" if  castename=="BAIRAGI" & state=="Maharashtra"
replace category="obc" if  castename=="BANJARA" & state=="Maharashtra"
replace category="obc" if  castename=="BELADAR" & state=="Maharashtra"
replace category="obc" if  castename=="BHAT" & state=="Maharashtra"
replace category="obc" if  castename=="BHOI" & state=="Maharashtra"
replace category="obc" if  castename=="DEVANGA" & state=="Maharashtra"
replace category="obc" if  castename=="DHANGAR" & state=="Maharashtra"
replace category="obc" if  castename=="DHOLI" & state=="Maharashtra"
replace category="obc" if  castename=="DOBHI" & state=="Maharashtra"
replace category="obc" if  castename=="GADARIA" & state=="Maharashtra"
replace category="obc" if  castename=="GURAV" & state=="Maharashtra"
replace category="obc" if  castename=="HATKAR" & state=="Maharashtra"
replace category="obc" if  castename=="JOGI" & state=="Maharashtra"
replace category="obc" if  castename=="KACCHI" & state=="Maharashtra"
replace category="obc" if  castename=="KOLI" & state=="Maharashtra"
replace category="obc" if  castename=="KOSHTI" & state=="Maharashtra"
replace category="obc" if  castename=="KUMHAR" & state=="Maharashtra"
replace category="obc" if  castename=="KUNBI" & state=="Maharashtra"
replace category="obc" if  castename=="LOHAR" & state=="Maharashtra"
replace category="obc" if  castename=="MALI" & state=="Maharashtra"
replace category="obc" if  castename=="PADMASALI" & state=="Maharashtra"
replace category="obc" if  castename=="TELI" & state=="Maharashtra"
replace category="obc" if  castename=="VADDERA" & state=="Maharashtra"
replace category="obc" if  castename=="YADAV" & state=="Maharashtra"
replace category="obc" if  castename=="BARAI" & state=="Punjab"
replace category="obc" if  castename=="BHAT" & state=="Punjab"
replace category="obc" if  castename=="CHHIPA" & state=="Punjab"
replace category="obc" if  castename=="DHIMAR" & state=="Punjab"
replace category="obc" if  castename=="DOBHI" & state=="Punjab"
replace category="obc" if  castename=="GADARIA" & state=="Punjab"
replace category="obc" if  castename=="GUJAR" & state=="Punjab"
replace category="obc" if  castename=="KAMBOJ" & state=="Punjab"
replace category="obc" if  castename=="KUNBI" & state=="Punjab"
replace category="obc" if  castename=="LOHAR" & state=="Punjab"
replace category="obc" if  castename=="MAHAR" & state=="Punjab"
replace category="obc" if  castename=="NAI" & state=="Punjab"
replace category="obc" if  castename=="TELI" & state=="Punjab"
replace category="obc" if  castename=="YADAV" & state=="Punjab"
replace category="obc" if  castename=="BANJARA" & state=="Rajasthan"
replace category="obc" if  castename=="BHAT" & state=="Rajasthan"
replace category="obc" if  castename=="CHHIPA" & state=="Rajasthan"
replace category="obc" if  castename=="DARJI" & state=="Rajasthan"
replace category="obc" if  castename=="DHAKAR" & state=="Rajasthan"
replace category="obc" if  castename=="GADARIA" & state=="Rajasthan"
replace category="obc" if  castename=="GUJAR" & state=="Rajasthan"
replace category="obc" if  castename=="JOGI" & state=="Rajasthan"
replace category="obc" if  castename=="KACCHI" & state=="Rajasthan"
replace category="obc" if  castename=="KALAL" & state=="Rajasthan"
replace category="obc" if  castename=="KUMHAR" & state=="Rajasthan"
replace category="obc" if  castename=="KUNBI" & state=="Rajasthan"
replace category="obc" if  castename=="LODH" & state=="Rajasthan"
replace category="obc" if  castename=="LOHAR" & state=="Rajasthan"
replace category="obc" if  castename=="MIRASI" & state=="Rajasthan"
replace category="obc" if  castename=="NAI" & state=="Rajasthan"
replace category="obc" if  castename=="TAMBOLI" & state=="Rajasthan"
replace category="obc" if  castename=="TELI" & state=="Rajasthan"
replace category="obc" if  castename=="YADAV" & state=="Rajasthan"
replace category="obc" if  castename=="AMBALAKAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="ARAYA" & state=="Tamil Nadu"
replace category="obc" if  castename=="BESTA" & state=="Tamil Nadu"
replace category="obc" if  castename=="BHOI" & state=="Tamil Nadu"
replace category="obc" if  castename=="CHETTI" & state=="Tamil Nadu"
replace category="obc" if  castename=="DEVANGA" & state=="Tamil Nadu"
replace category="obc" if  castename=="EZHAVA" & state=="Tamil Nadu"
replace category="obc" if  castename=="KALAL" & state=="Tamil Nadu"
replace category="obc" if  castename=="KAMSALI" & state=="Tamil Nadu"
replace category="obc" if  castename=="LABBAI" & state=="Tamil Nadu"
replace category="obc" if  castename=="MAPPILA" & state=="Tamil Nadu"
replace category="obc" if  castename=="MARATHA" & state=="Tamil Nadu"
replace category="obc" if  castename=="MARAVAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="MEENA" & state=="Tamil Nadu"
replace category="obc" if  castename=="NADAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="OTTAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="PARAVAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="THEVAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="UPPARA" & state=="Tamil Nadu"
replace category="obc" if  castename=="VANNAN" & state=="Tamil Nadu"
replace category="obc" if  castename=="VANNIYAR" & state=="Tamil Nadu"
replace category="obc" if  castename=="VELLALA" & state=="Tamil Nadu"
replace category="obc" if  castename=="YADAV" & state=="Tamil Nadu"
replace category="obc" if  castename=="BADHAI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="BANJARA" & state=="Uttar Pradesh"
replace category="obc" if  castename=="BHARBHUJA" & state=="Uttar Pradesh"
replace category="obc" if  castename=="DARJI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="GADARIA" & state=="Uttar Pradesh"
replace category="obc" if  castename=="GADDI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="GUJAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="JOGI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="KACCHI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="KAHAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="KISAN" & state=="Uttar Pradesh"
replace category="obc" if  castename=="KUMHAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="KUNBI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="LODH" & state=="Uttar Pradesh"
replace category="obc" if  castename=="LOHAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="LUNIYA" & state=="Uttar Pradesh"
replace category="obc" if  castename=="MALI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="MANIHAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="MIRASI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="NAI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="RANGREJ" & state=="Uttar Pradesh"
replace category="obc" if  castename=="SONAR" & state=="Uttar Pradesh"
replace category="obc" if  castename=="TAMBOLI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="TELI" & state=="Uttar Pradesh"
replace category="obc" if  castename=="YADAV" & state=="Uttar Pradesh"
replace category="obc" if  castename=="BARUI" & state=="West Bengal"
replace category="obc" if  castename=="JOGI" & state=="West Bengal"
replace category="obc" if  castename=="JULAHA" & state=="West Bengal"
replace category="obc" if  castename=="KACCHI" & state=="West Bengal"
replace category="obc" if  castename=="KAHAR" & state=="West Bengal"
replace category="obc" if  castename=="KUMHAR" & state=="West Bengal"
replace category="obc" if  castename=="NAI" & state=="West Bengal"
replace category="obc" if  castename=="TELI" & state=="West Bengal"
replace category="obc" if  castename=="YADAV" & state=="West Bengal"
replace category="obc" if  castename=="ARAYA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="BALIJA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="BANDARI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="BANJARA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="BESTA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="BHANGI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="DEVANGA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="GANIGA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="HATKAR" & state=="Andhra Pradesh"
replace category="obc" if  castename=="IDIGA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="JANGAM" & state=="Andhra Pradesh"
replace category="obc" if  castename=="KACCHI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="KAMAR" & state=="Andhra Pradesh"
replace category="obc" if  castename=="KAPU" & state=="Andhra Pradesh"
replace category="obc" if  castename=="KUMHAR" & state=="Andhra Pradesh"
replace category="obc" if  castename=="KURUBA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="MUDIRAJ" & state=="Andhra Pradesh"
replace category="obc" if  castename=="NAI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="PADMASALI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="PASI" & state=="Andhra Pradesh"
replace category="obc" if  castename=="PERIKA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="RAZAKA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="THOGATA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="VADDERA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="VANNIYAR" & state=="Andhra Pradesh"
replace category="obc" if  castename=="VELLALA" & state=="Andhra Pradesh"
replace category="obc" if  castename=="YADAV" & state=="Andhra Pradesh"


save "/Users/alee87/Dropbox/Job Reservation/DHS Analysis/casteDHSworking.dta",replace



















/*
replace category="sc" if  castename=="BANIA" & state=="Assam"
replace category="sc" if  castename=="DOBHI" & state=="Assam"
replace category="sc" if  castename=="KAIBARTA" & state=="Assam"
replace category="sc" if  castename=="MALI" & state=="Assam"
replace category="sc" if  castename=="BAURI" & state=="Bihar"
replace category="sc" if  castename=="BHUIYA" & state=="Bihar"
replace category="sc" if  castename=="CHAMAR" & state=="Bihar"
replace category="sc" if  castename=="DOBHI" & state=="Bihar"
replace category="sc" if  castename=="MAHAR" & state=="Bihar"
replace category="sc" if  castename=="MUSHAHAR" & state=="Bihar"
replace category="sc" if  castename=="PASI" & state=="Bihar"
replace category="sc" if  castename=="RAJVAR" & state=="Bihar"
replace category="sc" if  castename=="TURI" & state=="Bihar"
replace category="sc" if  castename=="BHANGI" & state=="Gujarat"
replace category="sc" if  castename=="CHAMAR" & state=="Gujarat"
replace category="sc" if  castename=="KORI" & state=="Gujarat"
replace category="sc" if  castename=="MAHAR" & state=="Gujarat"
replace category="sc" if  castename=="MANG" & state=="Gujarat"
replace category="sc" if  castename=="PASI" & state=="Gujarat"
replace category="sc" if  castename=="BHANGI" & state=="Haryana"
replace category="sc" if  castename=="CHAMAR" & state=="Haryana"
replace category="sc" if  castename=="DHANAK" & state=="Haryana"
replace category="sc" if  castename=="JULAHA" & state=="Haryana"
replace category="sc" if  castename=="KHATIK" & state=="Haryana"
replace category="sc" if  castename=="KOLI" & state=="Haryana"
replace category="sc" if  castename=="MEGH" & state=="Haryana"
replace category="sc" if  castename=="PASI" & state=="Haryana"
replace category="sc" if  castename=="BANJARA" & state=="Himachal Pradesh"
replace category="sc" if  castename=="BHANGI" & state=="Himachal Pradesh"
replace category="sc" if  castename=="CHAMAR" & state=="Himachal Pradesh"
replace category="sc" if  castename=="JOGI" & state=="Himachal Pradesh"
replace category="sc" if  castename=="JULAHA" & state=="Himachal Pradesh"
replace category="sc" if  castename=="KHATIK" & state=="Himachal Pradesh"
replace category="sc" if  castename=="KOLI" & state=="Himachal Pradesh"
replace category="sc" if  castename=="LOHAR" & state=="Himachal Pradesh"
replace category="sc" if  castename=="PASI" & state=="Himachal Pradesh"
replace category="sc" if  castename=="TELI" & state=="Himachal Pradesh"
replace category="sc" if  castename=="CHAMAR" & state=="Himachal Pradesh"
replace category="sc" if  castename=="DOM" & state=="Himachal Pradesh"
replace category="sc" if  castename=="JULAHA" & state=="Himachal Pradesh"
replace category="sc" if  castename=="MEGH" & state=="Himachal Pradesh"
replace category="sc" if  castename=="BAGDI" & state=="Madhya Pradesh"
replace category="sc" if  castename=="BALAI" & state=="Madhya Pradesh"
replace category="sc" if  castename=="BHANGI" & state=="Madhya Pradesh"
replace category="sc" if  castename=="CHAMAR" & state=="Madhya Pradesh"
replace category="sc" if  castename=="KATIYA" & state=="Madhya Pradesh"
replace category="sc" if  castename=="KHATIK" & state=="Madhya Pradesh"
replace category="sc" if  castename=="KOLI" & state=="Madhya Pradesh"
replace category="sc" if  castename=="KUMAR" & state=="Madhya Pradesh"
replace category="sc" if  castename=="MANG" & state=="Madhya Pradesh"
replace category="sc" if  castename=="PASI" & state=="Madhya Pradesh"
replace category="sc" if  castename=="BEDA" & state=="Maharashtra"
replace category="sc" if  castename=="BHANGI" & state=="Maharashtra"
replace category="sc" if  castename=="CHAMAR" & state=="Maharashtra"
replace category="sc" if  castename=="KATIYA" & state=="Maharashtra"
replace category="sc" if  castename=="KORI" & state=="Maharashtra"
replace category="sc" if  castename=="MADIGA" & state=="Maharashtra"
replace category="sc" if  castename=="MAHAR" & state=="Maharashtra"
replace category="sc" if  castename=="MALA" & state=="Maharashtra"
replace category="sc" if  castename=="MANG" & state=="Maharashtra"
replace category="sc" if  castename=="PASI" & state=="Maharashtra"
replace category="sc" if  castename=="BEDA" & state=="Orissa"
replace category="sc" if  castename=="BHOI" & state=="Orissa"
replace category="sc" if  castename=="DOBHI" & state=="Orissa"
replace category="sc" if  castename=="DOM" & state=="Orissa"
replace category="sc" if  castename=="HADI" & state=="Orissa"
replace category="sc" if  castename=="KATIYA" & state=="Orissa"
replace category="sc" if  castename=="KUMAR" & state=="Orissa"
replace category="sc" if  castename=="MADIGA" & state=="Orissa"
replace category="sc" if  castename=="MAHAR" & state=="Orissa"
replace category="sc" if  castename=="PANIKA" & state=="Orissa"
replace category="sc" if  castename=="PASI" & state=="Orissa"
replace category="sc" if  castename=="SAPARA" & state=="Orissa"
replace category="sc" if  castename=="BHANGI" & state=="Punjab"
replace category="sc" if  castename=="DHANAK" & state=="Punjab"
replace category="sc" if  castename=="JULAHA" & state=="Punjab"
replace category="sc" if  castename=="MEGH" & state=="Punjab"
replace category="sc" if  castename=="BADHAI" & state=="Rajasthan"
replace category="sc" if  castename=="BAGDI" & state=="Rajasthan"
replace category="sc" if  castename=="BARIWA" & state=="Rajasthan"
replace category="sc" if  castename=="BHANGI" & state=="Rajasthan"
replace category="sc" if  castename=="CHAMAR" & state=="Rajasthan"
replace category="sc" if  castename=="DOBHI" & state=="Rajasthan"
replace category="sc" if  castename=="KANJAR" & state=="Rajasthan"
replace category="sc" if  castename=="KHATIK" & state=="Rajasthan"
replace category="sc" if  castename=="KOLI" & state=="Rajasthan"
replace category="sc" if  castename=="MAHAR" & state=="Rajasthan"
replace category="sc" if  castename=="MEGH" & state=="Rajasthan"
replace category="sc" if  castename=="PASI" & state=="Rajasthan"
replace category="sc" if  castename=="RAWAT" & state=="Rajasthan"
replace category="sc" if  castename=="TURI" & state=="Rajasthan"
replace category="sc" if  castename=="KURAVAR" & state=="Tamil Nadu"
replace category="sc" if  castename=="MADIGA" & state=="Tamil Nadu"
replace category="sc" if  castename=="MALA" & state=="Tamil Nadu"
replace category="sc" if  castename=="PARAIYAR" & state=="Tamil Nadu"
replace category="sc" if  castename=="PULAYAN" & state=="Tamil Nadu"
replace category="sc" if  castename=="AGRI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="BALAI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="BHANGI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="BHARWAD" & state=="Uttar Pradesh"
replace category="sc" if  castename=="CHAMAR" & state=="Uttar Pradesh"
replace category="sc" if  castename=="DHANGAR" & state=="Uttar Pradesh"
replace category="sc" if  castename=="DOBHI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="DOM" & state=="Uttar Pradesh"
replace category="sc" if  castename=="KHATIK" & state=="Uttar Pradesh"
replace category="sc" if  castename=="KOL" & state=="Uttar Pradesh"
replace category="sc" if  castename=="KORI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="PANIKA" & state=="Uttar Pradesh"
replace category="sc" if  castename=="PASI" & state=="Uttar Pradesh"
replace category="sc" if  castename=="RAWAT" & state=="Uttar Pradesh"
replace category="sc" if  castename=="BAGDI" & state=="West Bengal"
replace category="sc" if  castename=="BAURI" & state=="West Bengal"
replace category="sc" if  castename=="BHANGI" & state=="West Bengal"
replace category="sc" if  castename=="BHUIYA" & state=="West Bengal"
replace category="sc" if  castename=="DOBHI" & state=="West Bengal"
replace category="sc" if  castename=="DOM" & state=="West Bengal"
replace category="sc" if  castename=="KAIBARTA" & state=="West Bengal"
replace category="sc" if  castename=="KHATIK" & state=="West Bengal"
replace category="sc" if  castename=="KOCH" & state=="West Bengal"
replace category="sc" if  castename=="LOHAR" & state=="West Bengal"
replace category="sc" if  castename=="LUNIYA" & state=="West Bengal"
replace category="sc" if  castename=="MAHAR" & state=="West Bengal"
replace category="sc" if  castename=="MALA" & state=="West Bengal"
replace category="sc" if  castename=="MALLAH" & state=="West Bengal"
replace category="sc" if  castename=="PASI" & state=="West Bengal"
replace category="sc" if  castename=="POD" & state=="West Bengal"
replace category="sc" if  castename=="TURI" & state=="West Bengal"
replace category="sc" if  castename=="KURAVAR" & state=="Andhra Pradesh"
replace category="sc" if  castename=="MADIGA" & state=="Andhra Pradesh"
replace category="sc" if  castename=="MALA" & state=="Andhra Pradesh"
replace category="sc" if  castename=="MANG" & state=="Andhra Pradesh"
replace category="st" if  castename=="ADIVASI" & state=="Assam"
replace category="st" if  castename=="RABHA" & state=="Assam"
replace category="st" if  castename=="ADIVASI" & state=="Bihar"
replace category="st" if  castename=="GOND" & state=="Bihar"
replace category="st" if  castename=="HO" & state=="Bihar"
replace category="st" if  castename=="KHERWAR" & state=="Bihar"
replace category="st" if  castename=="MUNDA" & state=="Bihar"
replace category="st" if  castename=="ORAON" & state=="Bihar"
replace category="st" if  castename=="PAHARIA" & state=="Bihar"
replace category="st" if  castename=="SANTHAL" & state=="Bihar"
replace category="st" if  castename=="ADIVASI" & state=="Gujarat"
replace category="st" if  castename=="BHIL" & state=="Gujarat"
replace category="st" if  castename=="GAMIT" & state=="Gujarat"
replace category="st" if  castename=="GOND" & state=="Gujarat"
replace category="st" if  castename=="ADIVASI" & state=="Haryana"
replace category="st" if  castename=="ADIVASI" & state=="Himachal Pradesh"
replace category="st" if  castename=="ADIVASI" & state=="Himachal Pradesh"
replace category="st" if  castename=="GADDI" & state=="Himachal Pradesh"
replace category="st" if  castename=="GUJAR" & state=="Himachal Pradesh"
replace category="st" if  castename=="ADIVASI" & state=="Madhya Pradesh"
replace category="st" if  castename=="BHIL" & state=="Madhya Pradesh"
replace category="st" if  castename=="GOND" & state=="Madhya Pradesh"
replace category="st" if  castename=="KAWAR" & state=="Madhya Pradesh"
replace category="st" if  castename=="KEER" & state=="Madhya Pradesh"
replace category="st" if  castename=="KORKU" & state=="Madhya Pradesh"
replace category="st" if  castename=="MUNDA" & state=="Madhya Pradesh"
replace category="st" if  castename=="ORAON" & state=="Madhya Pradesh"
replace category="st" if  castename=="SAHRIYA" & state=="Madhya Pradesh"
replace category="st" if  castename=="AANDH" & state=="Maharashtra"
replace category="st" if  castename=="ADIVASI" & state=="Maharashtra"
replace category="st" if  castename=="GOND" & state=="Maharashtra"
replace category="st" if  castename=="KORKU" & state=="Maharashtra"
replace category="st" if  castename=="ORAON" & state=="Maharashtra"
replace category="st" if  castename=="ADIVASI" & state=="Orissa"
replace category="st" if  castename=="BHUMIJ" & state=="Orissa"
replace category="st" if  castename=="GOND" & state=="Orissa"
replace category="st" if  castename=="KAWAR" & state=="Orissa"
replace category="st" if  castename=="KOLI" & state=="Orissa"
replace category="st" if  castename=="MUNDA" & state=="Orissa"
replace category="st" if  castename=="ORAON" & state=="Orissa"
replace category="st" if  castename=="SAHRIYA" & state=="Orissa"
replace category="st" if  castename=="SANTHAL" & state=="Orissa"
replace category="st" if  castename=="ADIVASI" & state=="Punjab"
replace category="st" if  castename=="ADIVASI" & state=="Rajasthan"
replace category="st" if  castename=="BHIL" & state=="Rajasthan"
replace category="st" if  castename=="MEENA" & state=="Rajasthan"
replace category="st" if  castename=="SAHRIYA" & state=="Rajasthan"
replace category="st" if  castename=="ADIVASI" & state=="Tamil Nadu"
replace category="st" if  castename=="KAMAR" & state=="Tamil Nadu"
replace category="st" if  castename=="ADIVASI" & state=="Uttar Pradesh"
replace category="st" if  castename=="BHIL" & state=="Uttar Pradesh"
replace category="st" if  castename=="BUKSA" & state=="Uttar Pradesh"
replace category="st" if  castename=="ADIVASI" & state=="West Bengal"
replace category="st" if  castename=="GOND" & state=="West Bengal"
replace category="st" if  castename=="KHARIA" & state=="West Bengal"
replace category="st" if  castename=="MUNDA" & state=="West Bengal"
replace category="st" if  castename=="ORAON" & state=="West Bengal"
replace category="st" if  castename=="SANTHAL" & state=="West Bengal"
replace category="st" if  castename=="GOND" & state=="Andhra Pradesh"
replace category="st" if  castename=="GOUD" & state=="Andhra Pradesh"
replace category="st" if  castename=="YANADI" & state=="Andhra Pradesh" 
*/
